import { Badge, Text } from "@mantine/core";

export default function BusinessRoleRenderer({ role }) {
  if (!role) {
    return <Text>N/A</Text>;
  }

  const roleMap = {
    AG_CSR: "银顾客",
    AU_CSR: "金顾客",
    AG_SHOP: "银店铺",
    AU_SHOP: "金店铺",
    AG_WHS: "银批发",
    AU_WHS: "金批发",
    AG_AGENT: "银代理",
    AU_AGENT: "金代理",
    MANAGER: "经理",
    AG_DIRECTOR: "总监",
    AU_DIRECTOR: "董事",
  };

  const roleLabel = roleMap[role] || "内部人员";
  const variant = role.startsWith("AG") ? "light" : "filled";
  let color;

  if (roleLabel.includes("店铺")) {
    color = "blue.5";
  }

  if (roleLabel.includes("批发")) {
    color = "teal.5";
  }

  if (roleLabel.includes("代理")) {
    color = "yellow.5";
  }
  if (roleLabel.includes("经理")) {
    color = "red.5";
  }

  if (roleLabel.includes("总监")) {
    color = "red.8";
  }
  if (roleLabel.includes("董事")) {
    color = "red.8";
  }

  return (
    <Badge variant={variant} size="md" radius="sm" color={color}>
      {roleLabel}
    </Badge>
  );
}
